#include "Color.h"
#include "File.h"
#include <string>
#include <SDL_opengl.h>


void Color::SetAll(float r, float g, float b, float a)
{
    m_r = r;
    m_g = g;
    m_b = b;
    m_a = a;
}

void Color::Apply(bool alpha)
{
    if(alpha)
        glColor4f(m_r, m_g, m_b, m_a);
    else
        glColor3f(m_r, m_g, m_b);
}

void Color::Neutralise()
{
    glColor3f(1.0f, 1.0f, 1.0f);
    glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
}
Color& Color::SetWhite()
{
    m_r = m_g = m_b = 1.0f;
    return *this;
}
Color& Color::SetBlack()
{
    m_r = m_g = m_b = 0.0f;
    return *this;
}
bool Color::Load(File* f)
{
    std::string store;
    if(!f->GetString(&store))
        return false;
    m_r = File::StoF(store);
    if(!f->GetString(&store))
        return false;
    m_g = File::StoF(store);
    if(!f->GetString(&store))
        return false;
    m_b = File::StoF(store);
    if(!f->GetString(&store))
        return false;
    m_a = File::StoF(store);

    return true;
}